<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>class和style的绑定</title>
    <style>
        .aClass {
            color: red;
        }

        .bClass {
            color: aqua;
        }

        .cClass {
            font-size: 30px;
        }
    </style>
</head>

<body>
    <div id="app">
        <h2>class绑定</h2>
        <p :class="a">class是个字符串</p>
        <p :class="{aClass:isA,bClass:isB,cClass:isC}">class是对象</p>
        <!-- <p :class="a">class是个字符串</p> -->
        <h2>style绑定</h2>
        <p :style="{color:activeColor,fontSize:fontSize+'px'}">:style="{color:activeColor,fontSize:fontSize+'px'}"</p>
        <button @click="update">更新</button>
    </div>
    <script src="https://cdn.bootcss.com/vue/2.5.16/vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                a: 'aClass',
                isA: true,
                isB: true,
                isC: true,
                activeColor: 'red',
                fontSize: 30
            },
            methods: {
                update() {
                    this.a = 'bClass';
                    this.isC = false;
                    this.activeColor = 'blue';
                    this.fontSize = 50;
                }
            }
        })
    </script>
</body>

</html>